package com.bookstore.dao.imp;

import com.bookstore.bean.User;
import com.bookstore.dao.UserDAO;


/**
 * Created by Admin on 2016/8/4.
 */

public class UserDaoImp extends BaseDao<User> implements UserDAO {

    @Override
    public User getUserByName(String username) {
        String sql="select userId,userName,password,accountId" +
                " from userinfo where userName=? ";
        return get(sql,username);
    }


    @Override
    public User getUserNaPa(String username, String password) {
        String sql="select userId,userName,password,accountId" +
                " from userinfo where userName=? and password=?";
        return get(sql,username,password);
    }

    @Override
    public void save(User user) {
        String sql="insert into userinfo (userName,password,accountId) values (?,?,?)";
        update(sql,user.getUserName(),user.getPassword(),user.getAccountId());
    }
}
